package com.yuankun.chat.server.impl;

import com.yuankun.chat.server.ChatHistoryReposity;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author：yuankun
 * @Package：com.yuankun.chat.server.impl
 * @Project：chat
 * @name：ChatHistoryReposity
 * @Date：2025/8/18 19:37
 * @Filename：ChatHistoryReposity
 */
@Service
public class ChatHistoryReposityImpl implements ChatHistoryReposity {

    private final Map<String,List<String>> history = new HashMap<>();
    @Override
    public void save(String type, String id) {
        // 实现保存聊天记录的逻辑
        if(!history.containsKey(type)) {
            history.put(type,new ArrayList<>());
        }
        List<String> ids = history.get(type);
        if(!ids.contains(id)) {
            ids.add(id);
        }
        history.put(type,ids);
    }


    @Override
    public List<String> getChatIds(String type) {
        // 实现获取聊天ID列表的逻辑
        if(history.containsKey(type)) {
            return history.get(type);
        }
        return null;
    }
}
